  open Ast
  open Eval

   let load_file f =
  	let ic = open_in f in
  		let n = in_channel_length ic in
  			let s = String.create n in
  			really_input ic s 0 n;
  			close_in ic;
  			(s) 

  let main () =
    let nomFichier =  Sys.argv.(1) in
    	let contenuFichier = load_file nomFichier in
			let lexbuf = Lexing.from_string contenuFichier in    
        try           
    		let nProgrammePrincipal =  Parser.programme Lexer.token lexbuf in
          begin
            if Eval.evalNoeudPrincipal nProgrammePrincipal then
              begin
                (* Afficher.afficherNoeudPrincipal nProgrammePrincipal ; *)
                AfficherDot.genereDotNoeudPrincipal nProgrammePrincipal; 
                flush stdout;
                let arbre_inter = ParcoursIntermediaire.construire nProgrammePrincipal in
                  begin
                    Afficher_ArbreIntermediaire.iafficher arbre_inter;
                    let arbre_sel = Selection_instruction.sel_iProgramme(arbre_inter) in
                      Afficher_selection_instruction.sel_afficher(arbre_sel)  
                  end
              end
            else
              print_endline("Erreur dans l'analyse de portée des variables")
          end
        with 
         | _ -> print_string ""

  let _ =  main ()

